<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增H5游戏')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-game-add">
           <div class="form-group">    
                <label class="col-sm-3 control-label">名字：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">名字(英文)：</label>
                <div class="col-sm-8">
                    <input name="nameEn" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图标：</label>
                <div class="col-sm-8">
                    <input id="icon" name="icon" class="form-control" type="hidden">
	                <div class="fileinput fileinput-new" data-provides="fileinput">
			        <div class="fileinput-new thumbnail" style="width:150px; height: 150px;">
			          <img >
			        </div>
			        <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 150px; max-height: 150px;"></div>
			        <div>
			          <span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span><span class="fileinput-exists">更改</span><input type="file" class="image"></span>
			          <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
			        </div>
			     </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">链接：</label>
                <div class="col-sm-8">
                    <input name="url" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">标签：</label>
                <div class="col-sm-8">
                    <input name="tag" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">生产商：</label>
                <div class="col-sm-8">
                    <input name="producer" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">来源：</label>
                <div class="col-sm-8">
                    <input name="source" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">横竖屏：</label>
                <div class="col-sm-8">
                    <select name="display" class="form-control m-b" th:with="type=${@dict.getType('game_display_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">国内外：</label>
                <div class="col-sm-8">
                    <select name="domestic" class="form-control m-b" th:with="type=${@dict.getType('game_domestic_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图1：</label>
                <div class="col-sm-8">
                    <input id="img1" name="img1" class="form-control" type="hidden">
	                <div class="fileinput fileinput-new" data-provides="fileinput">
			        <div class="fileinput-new thumbnail" style="width:234px; height: 133px;">
			          <img >
			        </div>
			        <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 234px; max-height: 133px;"></div>
			        <div>
			          <span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span><span class="fileinput-exists">更改</span><input type="file" class="image"></span>
			          <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
			        </div>
			     </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图2：</label>
                <div class="col-sm-8">
                    <input name="img2" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图3：</label>
                <div class="col-sm-8">
                    <input name="img3" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图4：</label>
                <div class="col-sm-8">
                    <input name="img4" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图5：</label>
                <div class="col-sm-8">
                    <input name="img5" class="form-control" type="text">
                </div>
            </div>
             <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">描述(短)：</label>
                <div class="col-sm-8">
                    <textarea name="shortDesc" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="status" value="">
                        <label th:for="status" th:text="未知"></label>
                    </div>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">推荐：</label>
                <div class="col-sm-8">
                    <input name="recom" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">玩次数(排序)：</label>
                <div class="col-sm-8">
                    <input name="rankPlayCount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">来源url：</label>
                <div class="col-sm-8">
                    <textarea name="sourceUrl" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支持iOS：</label>
                <div class="col-sm-8">
                    <input name="ios" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支持安卓：</label>
                <div class="col-sm-8">
                    <input name="android" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">外链检查：</label>
                <div class="col-sm-8">
                    <input name="linkCheck" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script type="text/javascript">
        var prefix = ctx + "game/game"
        $("#form-game-add").validate({
            focusCleanup: true
        });
        
        $('.image').on('change.bs.fileinput', function (e) {
        	var file = $(this)[0].files[0];
        	var data = new FormData();
	        data.append("file", file);
	        $.ajax({
	            type: "POST",
	            url: ctx + "common/uploadOSS",
	            data: data,
	            cache: false,
	            contentType: false,
	            processData: false,
	            dataType: 'json',
	            success: function(result) {
	                alert(result.url);
	            },
	            error: function(error) {
	                alert("图片上传失败。");
	            }
	        });
        	
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-game-add').serialize());
            }
        }
    </script>
</body>
</html>